package edu.umn.msse.farside.FourH.web;

import edu.umn.msse.farside.FourH.domain.Event;
import edu.umn.msse.farside.FourH.services.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Created by IntelliJ IDEA.
 * User: corcutt
 * Date: Mar 23, 2009
 * Time: 11:45:22 PM
 * To change this template use File | Settings | File Templates.
 */
@Controller
@RequestMapping("/deleteEvent")
public class DeleteEventController
{
    private EventService eventService;

    @Autowired
    public void setEventService(EventService eventService)
    {
        this.eventService = eventService;
    }

    @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST})
    public String deleteEventForm(@RequestParam(required=true) Long eventID) {
        Event event = eventService.getEvent(eventID);
        eventService.removeEvent(event);

        return "redirect:myEvents";
    }


}
